
package org.apache.solr.highlight;

import org.apache.lucene.search.highlight.Formatter;
import org.apache.lucene.search.highlight.SimpleHTMLFormatter;
import org.apache.solr.common.params.HighlightParams;
import org.apache.solr.common.params.SolrParams;

/**
 * Use the {@link org.apache.lucene.search.highlight.SimpleHTMLFormatter}
 */
public class HtmlFormatter extends HighlightingPluginBase implements SolrFormatter {

    @Override
    public Formatter getFormatter(String fieldName, SolrParams params) {

        numRequests++;
        params = SolrParams.wrapDefaults(params, defaults);

        return new SimpleHTMLFormatter(params.getFieldParam(fieldName, HighlightParams.SIMPLE_PRE, "<em>"), params.getFieldParam(fieldName, HighlightParams.SIMPLE_POST, "</em>"));
    }

    // SolrInfoMBeans methods
    @Override
    public String getDescription() {
        return "HtmlFormatter";
    }

    @Override
    public String getSource() {
        return "$URL: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/highlight/HtmlFormatter.java $";
    }
}
